#!/usr/bin/env python
# -*- coding: utf-8 -*-
# datetime: 30/10/2023 下午9:21
# Author: name
# File: __init__.py.py
# ide: PyCharm
# description:
from fastapi import FastAPI
from starlette.routing import Mount
from starlette.staticfiles import StaticFiles
from tortoise.contrib.fastapi import register_tortoise

from backend.app.api.environmet_api import environment_router
from backend.app.api.function_api import function_router
from backend.app.api.login_api import login_router
from backend.app.api.report_router import report_router
from backend.app.api.server_api import server_router
from backend.app.api.test_cases_api import test_case_router
from backend.app.api.variable_api import variable_router

app = FastAPI(
routes=[
        Mount('/reports', StaticFiles(directory='./autotest', html=True), 'report'),
    ]
)

register_tortoise(
    app,
    db_url=f'mysql://root:Sa_7654321@127.0.0.1:3306/auto_test',
    modules={
        "models": [
            "backend.app.models.function_model",
            "backend.app.models.variable_model",
            "backend.app.models.server_model",
            "backend.app.models.report_model",
            "backend.app.models.environment_model",
            "backend.app.models.login_model",
        ]
    },
    generate_schemas=True,
    add_exception_handlers=True,
)
# 注册路由

app.include_router(function_router)
app.include_router(variable_router)
app.include_router(server_router)
app.include_router(report_router)
app.include_router(environment_router)
app.include_router(login_router)
app.include_router(test_case_router)
